package com.study.kt._04project.encrypt

import java.lang.StringBuilder

fun main() {
    val str = "I love you"
    //将str转为ascii
    /*val sb = StringBuffer()
    for (c in str) {
        val result = c.toInt()
        sb.append("$result ")
    }
    println(sb.toString())*/

    //改为使用kotlin高阶函数实现
    val res = with(StringBuilder()) {
        str.forEach {
            append("${it.toInt()} ")
        }
        //返回值
        toString()
    }
    println(res)
}